package com.zkadmin.service.impl;

import java.util.Iterator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.mysema.query.types.Predicate;
import com.zkadmin.entity.SysSetting;
import com.zkadmin.repository.SysSettingRepository;
import com.zkadmin.service.SysSettingService;

@Service("sysSettingService")
public class SysSettingServiceImpl implements SysSettingService {
	@Autowired
	private SysSettingRepository repository;

	@Override
	public SysSetting save(SysSetting setting) {
		return repository.save(setting);
	}

	@Override
	public SysSetting getSysSetting() {
		Iterable<SysSetting> data = repository.findAll();
		SysSetting setting = null;
		for (Iterator<SysSetting> it = data.iterator(); it.hasNext();) {
			setting = it.next();
			break;
		}

		if (setting == null) {
			setting = new SysSetting();
			save(setting);
		}
		return setting;
	}

	@Override
	public Page<SysSetting> paging(Predicate predicate, Pageable pageable) {
		return null;
	}

	@Override
	public void delete(Long id) {
	}

}
